<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	
<HTA:APPLICATION ID="repcfm"  
    APPLICATIONNAME="monster"   
    BORDER="dialog"  
    MAXIMIZEBUTTON="no"  
    SCROLLFLAT="yes"  
    CAPTION="yes"  
    INNERBORDER="no"  
    ICON=""  
    SCROLL="no"  
    SHOWINTASKBAR="yes"  
    SINGLEINSTANCE="yes"  
    SYSMENU="yes"  
    WINDOWSTATE="normal" />  
<script language="javascript" src="data/data.js"></script>
<img id="img1" />
<script language="javascript">
var fileData = {};
var openFileList = [];

var isie6 = navigator.userAgent.indexOf("MSIE 6.0") != -1;

var swidth = 715;
var sheight = screen.height-150;
var saveData = null;
var running = false;
//netstat -aon|findstr "5037"
while (true) {  
    try {  
    var w = swidth, h = sheight;  
        window.resizeTo(w, h);  
        window.moveTo((window.screen.width - w) / 2, (window.screen.height - h) / 2);  
        break;  
    } catch (e) { continue; }  
}
window.onerror = function(a,b,c) {
	alert(a+b+c);
	return true;
}
function $(id)
{
	return document.getElementById(id);
}
function cover(color, alpha, magin)
{
	if(typeof(color) == 'undefined') color = '#666666';
	if(typeof(alpha) == 'undefined') alpha = 40;
	if(typeof(magin) == 'undefined') magin = 0;
	
	var alpha2 = alpha / 100;

	if(!this.$("cover_div_dasda")) {
	
		var div = document.createElement('div'); 
		div.id = 'cover_div_dasda';
		div.style.position = 'absolute';

		var width = swidth;
		var height = sheight;

		div.style.width = width + 'px';
		div.style.height = height + 'px';
		div.style.backgroundColor = color;
		div.style.left = '0px';
		div.style.top = '0px';
		div.style.zIndex = '5';
		div.style.filter = 'alpha(opacity=' + alpha + ')';
		div.style.opacity = alpha2;
		document.body.appendChild(div);
	}
}
function rm(id)
{
	if($(id)) $(id).parentNode.removeChild($(id));
}
function uncover()
{
	rm("cover_div_dasda");
}
function show_div(id)
{
	cover();
	$(id).style.zIndex = 100;

	var width = toInt($(id).style.width.replace("px", ''));
	var height = toInt($(id).style.height.replace("px", ''));

	var cwidth = swidth;
	var cheight = sheight;


	var left = parseInt((cwidth-width)/2);
	var top = parseInt((cheight-height)/2)-20;

	$(id).style.left = left + 'px';
	$(id).style.top = top + 'px';
	
	$(id).style.display = 'block';
}
function hide_div(id, p)
{
	if(p !== false) uncover();
	$(id).style.display = 'none';
}
function readSaveData() {
	saveData = {};
	var s = readFile("config.ini");
	var a = s.split("\n");
	for(var i in a) {
		var line = a[i].trim();
		if(line == '') continue;
		var a2 = line.split("=");
		if(a2.length == 2) {
			saveData[a2[0]] = decodeURIComponent(a2[1]);
		}
	}
}
function getSaveData(key) {
	if(saveData == null) {
		readSaveData();
	}
	return saveData[key];
}
function setSaveData(key, value) {
	if(saveData == null) {
		readSaveData();
	}
	saveData[key] = value;
	var s = '';
	for(var i in saveData) {
		s += i + "=" + encodeURIComponent(saveData[i]) + "\n";
	}
	writeFile("config.ini", s);
}
function cmdexec(cmd) {
	var a = new ActiveXObject("wscript.shell");
	a.run("cmd.exe /c " + cmd, 0, false);
}
String.prototype.replaceAll=function(f, r) {
	return this.split(f).join(r);
}
String.prototype.endWith=function(s){
  if(s==null||s==""||this.length==0||s.length>this.length)
     return false;
  if(this.substring(this.length-s.length)==s)
     return true;
  else
     return false;
  return true;
 }
 String.prototype.startWith=function(s){
  if(s==null||s==""||this.length==0||s.length>this.length)
   return false;
  if(this.substr(0,s.length)==s)
     return true;
  else
     return false;
  return true;
 }
String.prototype.trim=function() 
{ 
	if(this == null || typeof(this) == "undefined") return "";
	for(var i = 0 ; i<this.length && (this.charAt(i)==" " || this.charAt(i)=="　" || this.charAt(i)=="\t" || this.charAt(i)=="\r") ; i++) ; 
	for(var j =this.length; j>0 && (this.charAt(j-1)==" " || this.charAt(j-1)=="　" || this.charAt(j-1)=="\t" || this.charAt(j-1)=="\r") ; j--) ; 
	if(i>j) return ""; 
	return this.substring(i,j); 
}
function toInt(n) {
	var n2 = parseInt(n);
	if(isNaN(n2)) return 0;
	return n2;
}

function fileExists(fn)
{
	var oFSO = new ActiveXObject("Scripting.FileSystemObject");
	return oFSO.fileExists(fn);
}
function fileSize(fn)
{
	if(!fileExists(fn)) return 0;
	var oFSO = new ActiveXObject("Scripting.FileSystemObject");
	var f = oFSO.getFile(fn);
	return f.size;
}
function checkDir(path)
{
	var oFSO = new ActiveXObject("Scripting.FileSystemObject");
	if(!oFSO.FolderExists(path)) {
		oFSO.CreateFolder(path);
	}
}
function readFile(fn){
	if(!fileExists(fn)) return "";
	var Stream = new ActiveXObject("ADODB.Stream");
	Stream.Type = 2;
	Stream.charset="GBK"; 
	Stream.Open();
	var str;
	try{
		Stream.LoadFromFile(fn);
		str = Stream.ReadText();
	} catch (e) {
		var r = "temp\\"+new Date().getTime()+""+Math.random();
		var oFSO = new ActiveXObject("Scripting.FileSystemObject");
		oFSO.CopyFile(fn, r);
		var s2 = readFile(r);
		delFile(r);
		return s2;
	}
	Stream.Close();
	return str;
}
function writeFile(fn, str) {
	var Stream = new ActiveXObject("ADODB.Stream");
	Stream.Type = 2;
	Stream.charset="GBK"; 
	Stream.Open();
	
	Stream.WriteText(str);
	Stream.SaveToFile(fn, 2);
	Stream.Close();
}
function delFile(fn){
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	try{ fso.DeleteFile(fn); } catch(e){}
}
function moveFile(src, des){
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	try{ fso.MoveFile(src, des); } catch(e){}
}
function sizeStr(s) {
	s = toInt(s);
	var d = ['字节', 'KB', 'MB', 'GB'];
	var n = 0;
	while(s >= 1024) {
		s = s/1024;
		n++;
	}
	return s.toFixed(2)+d[n];
}
var selfDir;
function exec(cmd, noreturn, nosplit) {
	if(running) {
		alert("有任务正在运行中，请稍候操作！");
		return false;
	}
	running = true;
	var getd = (cmd == 'adb devices');
	checkDir("temp");
	var r = "temp\\"+new Date().getTime()+""+Math.random();
	var a = new ActiveXObject("wscript.shell");
	if(!cmd.startWith("adb")) {
		if(isRoot && cmd.startWith("shell")) cmd = cmd.replace("shell", "shell su -c");
		cmd = 'adb -s "'+devices[nowDevice]+'" ' + cmd;
	}
	cmd = "cmd.exe /c " + cmd;
	if(!noreturn) cmd += ' > "'+selfDir+r+'" 2>&1';
	//alert(cmd);
	try{
		a.run(cmd, 0, true);
	} catch(e) {
		running = false;
		return false;
	}
	if(!noreturn) {
		var s = readFile(r);
		delFile(r);
		if(!getd && s.startWith("error")) {
			if(s.indexOf("device not found") != -1) {
				devices = [];
				nowDevice = 0;
				nowPath = '/sdcard/';
				sizeN = {};
				fnN = {};
				alert("设备未连接！");
			}
			else alert("出错！");
			running = false;
			return false;
		}
		if(!nosplit) {
			a = [];
			s = s.split("\n");
			for(var i = 0; i < s.length; i++) {
				var s2 = s[i].trim();
				if(s2 == "") continue;
				a.push(s2);
			}
			running = false;
			return a;
		}
		running = false;
		return s;
	}
	running = false;
}
function chooseDir() {
	var objShell = new ActiveXObject("Shell.Application") 
	var objFolder = objShell.BrowseForFolder(0, "选择目标文加夹:", 0, new ActiveXObject("Wscript.Shell").SpecialFolders("Desktop")) ;
	if(!objFolder || !objFolder.Self) return null;
	var path = objFolder.Self.Path;
	if(!path) return null;
	if(!path.endWith("\\")) path += "\\";
	return path;
}
var devices = [];
var nowDevice = -1;
function getDevices() {
	var a= exec("adb devices");
	for(var i in a) {
		if(a[i].toLowerCase().endWith("device")) {
			var a2 = a[i].replaceAll("\t", " ").split(" ");
			devices.push(a2[0]);
		}
	}
}
var sizeN = null;
var fnN = null;
var isRoot = false;
var dirPermit = {};
function getN() {
	sizeN = {};
	fnN = {};

	var sizeF = {};
	var fnF = {};
	
	var a1 = exec('shell "ls -l /system/etc/"');
	if(!a1) return ;
	var a2 = exec('shell "ls -l /"');
	var a = a1.concat(a2);
	for(var i in a) {
		var line = a[i].replaceAll("\t", " ");
		while(line.indexOf("  ") != -1) line = line.replaceAll("  ", " ");
		var a2 = line.split(" ");
		var ps = a2[0];
		if(!ps.match(/^[drwxl\-]{10}$/)) continue;
		var ftype = ps.substr(0, 1);
		
		for(var j in a2) {
			if(j == 0) continue;
			var s2 = a2[j];
			if(s2.match(/\d{5,10}/)) {
				if(!sizeF[ftype]) sizeF[ftype] = {};
				sizeF[ftype][j] = toInt(sizeF[ftype][j]) + 1;
			}
			if(s2 == "permissions" || s2 == "vold.fstab" || s2 == "ppp" || s2 == "wifi" || s2 == "data" || s2 == "cache" || s2 == "sdcard" || s2 == "etc" || s2 == "hosts" || s2 == "init.rc" || s2 == "system_fonts.xml") {
				//alert(ftype);return;
				if(!fnF[ftype]) fnF[ftype] = {};
				fnF[ftype][j] = toInt(fnF[ftype][j]) + 1;
			}
		}
	}

	for(var i in sizeF) {
		var max = 0, maxI = 0;
		for(var j in sizeF[i]) {
			if(sizeF[i][j] > max) {
				max = sizeF[i][j];
				maxI = j;
			}
		}
		sizeN[i] = maxI;
	}
	if(!sizeN["l"]) sizeN["l"] = sizeN["d"];
	for(var i in fnF) {
		var max = 0, maxI = 0;
		for(var j in fnF[i]) {
			if(fnF[i][j] > max) {
				max = fnF[i][j];
				maxI = j;
			}
		}
		fnN[i] = maxI;
	}

	if(!fnN["l"]) fnN["l"] = fnN["d"];

	//for(var i in fnN) {alert(i+": "+fnN[i]);}
}
function getListData(path) {
	if(fnN == null || !fnN["-"]) getN();
	if(fnN == null || !fnN["-"]) return [];

	var a = exec('shell "ls -al \''+path+'\'"');
	if(a === false) return false;
	var fList = [];
	for(var i in a) {
		var line = a[i].replaceAll("\t", " ");
		while(line.indexOf("  ") != -1) line = line.replaceAll("  ", " ");
		var a2 = line.split(" ");

		var ps = a2[0];
		if(!ps.match(/^[drwxl\-]{10}$/)) continue;
		var ftype = ps.substr(0, 1);

		var fn = a2.slice(fnN[ftype]).join(" ");
		var size;
		if(!sizeN[ftype]) size = 0;
		else size = a2[sizeN[ftype]];
		
		var dn1;
		if(!sizeN[ftype]) dn1 = sizeN["-"] - 1;
		else dn1 = sizeN[ftype];
		var dn2 = fnN[ftype];
		var date = a2.splice(dn1+1, dn2-dn1-1).join(" ");
		
		if(ftype == 'l') {
			fn = fn.split("->")[0].trim();
		}
		fList.push([ftype, fn, size, date, ps]);
	}
	return fList;
}
function setWaitMsg(msg) {
	if(msg.length > 25) msg = msg.substr(0, 25)+"..";
	$("waitTipMsg").innerHTML = msg;
}
function showWait(msg) {
	setWaitMsg(msg);
	show_div("tipFDiv");
}
function hideWait() {
	hide_div("tipFDiv");
}
var nowPath = '/sdcard/';
function listFn() {
	var list = getListData(nowPath);
	if(list === false) return false;
	if(list.length == 0 && nowPath == "/data/") {
		alert("没有权限！请使用ROOT方式运行！");
	}
	list = list.sort(function(a, b) {
		var p = {'d':1, '-':5,'l':1};
		if(toInt(p[a[0]]) != toInt(p[b[0]])) {
			return toInt(p[a[0]])-toInt(p[b[0]]);
		} else {
			if(a[1].toLowerCase() > b[1].toLowerCase()) return 1;
			else return -1;
		}
	});
	if(nowPath != '/') list = [['parent', '..', 0, '']].concat(list);
	var html = '';
	for(var i in list) {
		var finfo = list[i];
		var ftype = finfo[0];
		var src = '';
		if(ftype == 'd' || ftype == 'parent') src = "folder.png";
		else if(ftype == '-') src = "file.png";
		else if(ftype == 'l') src = "ln.png";
		else src = "file.png";

		var sizestr = '';
		if(ftype == '-') {
			sizestr = sizeStr(finfo[2]);
		}
		html += '<div style="height:50px;background-color: #ffffff;border-bottom:1px solid #DCDCDC;position:relative" onmouseover="this.style.backgroundColor=\'#eeeeee\';" onmouseout="this.style.backgroundColor=\'#ffffff\';">';
		html += '	<div style="position: absolute;left: 10px;top: 0px;width:520px;height:50px;cursor:pointer;" onclick="clickFn(\''+ftype+'\', \''+finfo[1]+'\', \''+finfo[2]+'\', \''+finfo[4]+'\')"><img src="img/'+src+'" width="40" height="40" style="margin-top:4px" /></div>';
		html += '	<div style="position: absolute;left: 60px;top: 5px;cursor:pointer;" onclick="clickFn(\''+ftype+'\', \''+finfo[1]+'\', \''+finfo[2]+'\', \''+finfo[4]+'\')">'+finfo[1]+'<br /><span style="color:#999999;font-size:11px">'+sizestr+'</span></div>';
		if(ftype != 'parent') html += '	<div style="position: absolute;left: 550px;top: 13px;"><span style="color:blue;font-size:13px;cursor:pointer;text-decoration:underline" href="javascript:;" onclick="downloadFn(\''+ftype+'\', \''+finfo[1]+'\', \''+finfo[2]+'\', \''+finfo[4]+'\')">下载</span>&nbsp;&nbsp;<span style="color:red;font-size:13px;cursor:pointer;text-decoration:underline" href="javascript:;" onclick="delFn(\''+ftype+'\', \''+finfo[1]+'\')">删除</span></div>';
		html += '</div>';
	}
	html += '<div style="padding:3px 0px 3px 17px">作者: shiming</div>';
	$("listDiv").innerHTML = html;
	var a = nowPath.split("/");
	var html = '';
	var s = '';
	for(var i in a) {
		if(i == a.length-1) break;
		s += a[i]+"/";
		html += '<span onclick="gotoPath(\''+s+'\')" class="pathlink" onmouseover="this.className=\'pathlink2\';" onmouseout="this.className=\'pathlink\';">'+a[i]+'/</span>';
	}
	$("nowPath").innerHTML = html;
}
function gotoPath(path) {
	nowPath = path;
	listFn();
}
function clickFn(ftype, fn, size, permit) {
	if(running) {
		alert("有任务正在运行中，请稍候操作！");
		return false;
	}
	if(ftype == 'd' || ftype == 'l') {
		nowPath += fn + "/";
		listFn();
	} else if(ftype == 'parent'){
		goParent();
	} else if(ftype == '-') {
		downloadFn(ftype, fn, size, permit);
	}
}
function getPerminNum(s) {
	if(!s) return '777';
	function getPerminNum_2(s2) {
		var n = 0;
		if(s2.substr(0,1) == 'r') n+=4;
		if(s2.substr(1,1) == 'w') n+=2;
		if(s2.substr(2,1) == 'x') n+=1;
		return n;
	}
	return getPerminNum_2(s.substr(1,3))+""+getPerminNum_2(s.substr(4,3))+""+getPerminNum_2(s.substr(7,3));
}
function adbdownload(src, des, per, size) {
	var pf = des.split("\\")[0];
	var rn = pf+"\\"+new Date().getTime()+""+Math.random();
	
	var fna = des.split("\\");fna=fna[fna.length-1];
	setWaitMsg("正在下载 0% "+fna);
	var itv = null;
	if(toInt(size) > 0) {
		itv = setInterval(function() {
			var size2 = fileSize(rn);
			if(size2 != 0) setWaitMsg("正在下载 "+ (size2/size*100).toFixed(2)+"% "+fna);
		}, 500);
	}

	var s = exec('pull "'+src + '" "' + rn + '"', false, 1);
	
	if(s.toLowerCase().indexOf("denied") != -1 && isRoot) {
		var oldPerMit = getPerminNum(per);
		exec('shell "chmod 777 \''+src + '\'"', 1);
		s = exec('pull "'+src + '" "' + rn + '"', 1);
		exec('shell "chmod '+oldPerMit+' \''+src + '\'"', 1);
	}
	if(itv != null) { clearInterval(itv); itv = null;}
	if(fileExists(rn)) {
		moveFile(rn, des);
	}
}
function downloadFn(ftype, fn, size, permit) {
	
	var cdir = chooseDir();
	if(cdir) {
		var suc = false;
		showWait("正在下载");
		if(ftype == '-') {
			var desFn = cdir + fn;
			

			
			adbdownload(nowPath+fn, desFn, permit, size);

			hideWait();
			
			suc = fileExists(desFn);
		} else if(ftype == 'd') {
			var desDir = cdir + fn;
			var hasCheckDir = {};
			function getDir(dir) {
				var list = getListData(dir);
				var dn = dir.replace(nowPath, "");
				if(!hasCheckDir[dn]) {
					checkDir(cdir+dn.replaceAll("/", "\\"));
					hasCheckDir[dn] = 1;
				}
				for(var i in list) {
					var finfo = list[i];
					var ftype = finfo[0];
					var fn = finfo[1];
					var size2 = finfo[2];
					var permit2 = finfo[4];
					if(ftype == 'd') {
						getDir(dir+fn+"/");
					} else if(ftype == '-') {
						var desFn = cdir+dn.replaceAll("/", "\\")+fn;
						adbdownload(nowPath+dn+fn, desFn, permit2, size2);
					}
				}
			}
			getDir(nowPath + fn + "/");
			suc = 1;
		}
		hideWait();
		if(suc) {
			alert("下载成功！");
		} else {
			if(ftype == 'l') {
				alert("暂不支持下载链接文件！");
			} else {
				alert("下载失败！");
			}
		}
	}
}
function checkRs(s) {
	if(s.indexOf("fail") != -1 || s.indexOf("not") != -1) {
		if(s.toLowerCase().indexOf("denied") != -1) {
			alert("没有权限！请使用ROOT方式运行！");
		} else {
			alert("操作失败！");
		}
		return false;
	}
	return true;
}
function delFn(ftype, fn) {
	var desFn = nowPath + fn;
	if(!confirm("确定要删除"+desFn+"？")) return ;
	showWait("正在删除");
	var s = execCheckReadOnly('shell "rm -rf \''+desFn+'\'"', desFn);
	if(s.toLowerCase().indexOf("only") == -1 && s.toLowerCase().indexOf("denied") == -1 && s.toLowerCase().indexOf("fail") != -1) s = exec('shell "rm -r \''+desFn+'\'"', false, 1);

	hideWait();
	if(checkRs(s)) {
		listFn();
	}
}
function getPstr(ps) {
	var a = ps.split("/");
	var s = a.slice(0, a.length-2);
	if(s.length == 0) return "/";
	return s.join("/")+"/";
}
function goParent() {
	nowPath = getPstr(nowPath);
	listFn();
}
function adbmkdir(dn) {
	return execCheckReadOnly('shell "mkdir \'' + dn + '\'"', dn);
}
function newFolder() {
	var dn = prompt("请输入新建文件夹名称", "");
	if(dn != null) {
		var s = adbmkdir(nowPath+dn);
		if(checkRs(s)) {
			listFn();
		}
		
	}
}
function changeDevice(n) {
	nowDevice = toInt(n);
	nowPath = '/sdcard/';
	sizeN = {};
	fnN = {};
	dirPermit = {};
	isRoot = false;
	$("isRootCheck").checked = false;
	listFn();
}
function flushDevice() {
	var lastDevice = devices[nowDevice];
	devices = [];
	
	getDevices();
	$("deviceSelect").length = 0;
	for(var i in devices) {
		var o = new Option(devices[i], i);
		$("deviceSelect").options.add(o);
	}
	if(devices.length > 0) {
		if(nowDevice == -1 || lastDevice == '') {
			nowDevice = 0;
			changeDevice(0);
		} else {
			var lastN = nowDevice;
			nowDevice = 0;
			for(var i in devices) {
				if(devices[i] == lastDevice) {
					nowDevice = i;
					break;
				}
			}
			if(lastN != nowDevice) changeDevice(nowDevice);
		}
		listFn();
	}
}
function setRoot(obj) {
	if(obj.checked) {
		var s = getSaveData("hasTipRoot");
		if(!s) {
			if(!confirm("ROOT方式运行需要确保手机已ROOT，并且第一次运行手机端可能会弹出是否允许ROOT的确认对话框，请选择始终允许！否则无法正常运行！是否继续？")) {
				obj.checked = false;
				return ;
			}
			setSaveData("hasTipRoot", "1");
		}
	}
	isRoot = obj.checked;
	if(isRoot) listFn();
}
function execCheckReadOnly(cmd, des) {
	var s = exec(cmd, false, 1);
	if(s.toLowerCase().indexOf('read') != -1 && s.toLowerCase().indexOf('only') != -1) {
		var a2 = des.split("/");
		
		s = exec('shell "mount -o rw,remount /'+a2[1]+'"', false, 1);
		if(s.toLowerCase().indexOf("denied") != -1 || s.toLowerCase().indexOf("permitt") != -1) return "denied";
		s = exec(cmd, false, 1);
	}
	return s;
}
function adbupload(src, des) {
	var s = execCheckReadOnly('push "'+src + '" "' + des + '"', des);

	if(s.toLowerCase().indexOf("denied") != -1) {
		if(!isRoot) {
			alert("没有权限！请使用ROOT方式运行！");
			return ;
		}
		var r = new Date().getTime()+""+Math.random();
		
		if(des.startWith("/data/") || des.startWith("/system/") || des.startWith("/cust/")) {
			var a2 = des.split("/");
			execCheckReadOnly('shell "mkdir /'+a2[1]+'/pcre"', des);
			exec('push "'+src + '" "/'+a2[1]+'/pcre/1.data"', 1);
			exec('shell "mv /'+a2[1]+'/pcre/1.data \''+des+'\'"', 1);
			exec('shell "rm /'+a2[1]+'/1.data"', 1);
		} else {
			exec('push "'+src + '" "/sdcard/' + r + '"', 1);
			var s2 = execCheckReadOnly('shell "cat \'/sdcard/'+r + '\' > \'' + des + '\'"', des);
		
			exec('shell "rm \'/sdcard/'+r + '\'"', 1);
		}
	}
}
function uploadFile() {
	if(nowPath == '/') {
		alert("根目录不能上传！");
		return ;
	}
	$("fileInput").click();
}
function doUpload() {
	var fp = $("fileInput").value;
	document.form1.reset();
	
	
	var fn = fp.split("\\");
	fn = fn[fn.length - 1];
	showWait("正在上传");
	adbupload(fp, nowPath + fn);
	listFn();
	hideWait();
}
function getDirPer(dn) {
	if(dirPermit[dn]) return dirPermit[dn];
	var dn2 = getPstr(dn);
	var dname = dn.split("/");
	dname = dname[dname.length - 2];
	var list = getListData(dn2);
	for(var i in list) {
		var finfo = list[i];
		if(finfo[1] == dname) {
			dirPermit[dn] = finfo[4];
			return finfo[4];
		}
	}
	return false;
}
function uploadFolder() {
	if(nowPath == '/') {
		alert("根目录不能上传！");
		return ;
	}
	function getDn(s) {
		if(s.endWith("\\")) s = s.substr(0, s.length-1);
		var a2 = s.split("\\");
		return a2[a2.length - 1];
	}
	
	var cdir = chooseDir();
	if(!cdir) return ;

	var dnr = getDn(cdir);
	var pd = cdir.split("\\");
	pd = pd.slice(0, pd.length-2).join("\\")+"\\";


	function listDir(dn) {
		var fso = new ActiveXObject("Scripting.FileSystemObject");
		var folder = fso.GetFolder(dn);

		var fc = new Enumerator(folder.SubFolders);
		for (; !fc.atEnd(); fc.moveNext())
		{
			var dn2 = fc.item()+"";
			if(dn2.endWith("\\")) dn2 = dn2.substr(0, dn2.length-1);
			
			var desDir = dn2.replace(pd, '').replaceAll("\\", "/");
			adbmkdir(nowPath + desDir);
			if(dn2.indexOf(":\\") == -1) dn2 = dn + dn2;
			dn2 += "\\";
			listDir(dn2);
		}

		var fc2 = new Enumerator(folder.Files);
		for (; !fc2.atEnd(); fc2.moveNext()) {
			var fn = fc2.item()+"";
			if(fn.indexOf(":\\") == -1) fn = dn + fn;

			var desFn = fn.replace(pd, '').replaceAll("\\", "/");
			setWaitMsg("正在上传 "+getDn(fn));
			adbupload(fn, nowPath + desFn)
		}
	}
	showWait("正在上传");
	var s = adbmkdir(nowPath + dnr);
	if(s.toLowerCase().indexOf("denied") != -1) {
		alert("没有权限！请使用ROOT方式运行！");
		hideWait();
		return ;
	}
	listDir(cdir);
	listFn();
	hideWait();
}
window.onload = function() {
	/*
	return ;*/
	var dir = document.location+""; 
	dir = dir.replace("file:///", "");
	dir = dir.replace(/\//g, "\\");
	var a2 = dir.split("\\");
	var dir2 = '';
	for(var i = 0; i < a2.length-1; i++) {
		dir2 += a2[i]+"\\";
	}
	selfDir = dir2;

	cmdexec('del /Q/F "'+selfDir+'temp\\*"');
	showWait("请稍候...");
	flushDevice();
	hideWait();
	if(devices.length == 0) {
		alert("未连接设备！");
	}
}

</script>

<style type="text/css">
	html, body {
		margin: 0;
		padding: 0;
		font-size:14px;
		color:#333333;
		font-family:微软雅黑;
	}

.left {
		position: absolute;
		left: 0px;
		top: 0px;
		width: 700px;
		background-color: #ffffff;
		border: solid 1px #DCDCDC;
		border-left-width: 0;
	}
.bt {
	cursor:pointer;
}
.pathlink {
	text-decoration:none;color:#333333;cursor:pointer;
}
.pathlink2 {
	text-decoration:none;color:red;cursor:pointer;
}
.tglink {
	text-decoration:underline;color:#009900;
}
.tglink:hover {
	text-decoration:underline;color:red;
}
</style>
</head>

<body>
<script language="javascript">document.write('<div class="left" style="height:'+(sheight-37)+'px">');</script>
	<div style="height:38px;background-color: #F3F3F3;border-bottom:1px solid #DCDCDC;text-align:center;">
		<div style="margin-top:8px;text-align:left;padding-left:10px">当前路径: <span id="nowPath"></span></div>
	</div>
	<script language="javascript">document.write('<div id="listDiv" style="height:'+(sheight-120)+'px;overflow-y:scroll;overflow-x:hidden">');</script>

	</div>
	<div style="height:43px;background-color: #F3F3F3;border-top:1px solid #DCDCDC">
		<div style="margin-top:8px;float:left;width:420px;text-align:left;padding-left:10px;"><input type="button" class="bt" onclick="listFn()" value="刷新" /> <input type="button" class="bt" onclick="newFolder()" value="新建目录" /> <input type="button" class="bt" onclick="uploadFile()" value="上传文件" /> <input type="button" class="bt" onclick="uploadFolder()" value="上传目录" />&nbsp;&nbsp
		<input type="checkbox" style="cursor:pointer;" onclick="setRoot(this)" id="isRootCheck" />ROOT方式
		</div>
		<div style="margin-top:8px;float:right;width:260px;text-align:right;padding-right:10px;">
			设备: <select id="deviceSelect" onchange="changeDevice(this.value)" style="width:110px"></select>
			<input type="button" class="bt" onclick="flushDevice()" value="刷新设备" />
		</div>
	</div>
</div>

<div id="tipFDiv" style="position:absolute; width:350px; height:60px; background:#ffffff; border: 1px solid #999999; display:none;text-align:center;padding-top:15px"><nobr><img src="img/loading.gif" style="vertical-align: middle;" />&nbsp;&nbsp;<span id="waitTipMsg"></span></nobr></div>
<form name="form1"><input type="file" id="fileInput" style="display:none" onchange="doUpload()" /></form>
</body>
</html>